<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>客户经理修改赎回申请信息</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <%--<jsp:include page="assParkCommon.jsp" flush="true" /><!-- 时间格式转换 -->--%>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div class="sqPanel">
            <div class="sqPanel_head inL">
                <span>--------项目及还款信息--------</span>
            </div>
        </div>
        <div id="pageInTab" class="pageInTab">
            <div class="fieldset1 tabel_col clearFix">
                <div class="fieldBox col_33">
                    <div class="label">合同编号</div>
                    <div class="field">
                        <span name="lsCntNo" id="lsCntNo">${redm.lsCntNo}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">承租人名称</div>
                    <div class="field">
                        <span>${redm.cstNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">第三方机构</div>
                    <div class="field">
                        <span>${redm.fundRasInsNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">租赁期数</div>
                    <div class="field">
                        <span name="fundRasInsNm" id="fundRasInsNm">${redm.lsPd}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">合同总金额</div>
                    <div class="field">
                        <span>${redm.contAmt == null ? 0 : redm.contAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">融资总金额</div>
                    <div class="field">
                        <span>${redm.actLsAmt == null ? 0 : redm.actLsAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">实际应收金额</div>
                    <div class="field">
                        <span>${redm.relActAmt == null ? 0 : redm.relActAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">应收租金合计</div>
                    <div class="field">
                        <span>${redm.totalActAmt == null ? 0 : redm.totalActAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">实收租金合计</div>
                    <div class="field">
                        <span>${redm.totalRelRcptAmt == null ? 0 : redm.totalRelRcptAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">逾期金额</div>
                    <div class="field">
                        <span>${redm.ovdAmt == null ? 0 : redm.ovdAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">罚息金额</div>
                    <div class="field">
                        <span>${redm.pnlAmt == null ? 0 : redm.pnlAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">逾期天数</div>
                    <div class="field">
                        <span>${redm.ovdDay == null ? 0 : redm.ovdDay}</span>
                    </div>
                </div>
            </div>

            <div class="sqPanel">
                <div class="sqPanel_head inL">
                    <span>--------项目产品信息及放款信息--------</span>
                </div>
            </div>
            <!-- 列表显示块 -->
            <div id="ligergrid3" class="sq-grid"></div>
            <!--资方赎回信息-->
            <c:if test="${isShowInsRedmInterfaceInfo == 1 && redm.insPayTime != null}">
                <div class="sqPanel">
                    <div class="sqPanel_head inL">
                        <span>--------资方赎回接口信息--------</span>
                    </div>
                </div>
                <!-- 资方赎回接口显示块 -->
                <div id="ligergrid2" class="sq-grid"></div>
            </c:if>
            <form id="insRedmApplyForm">
                <!--赎回原因-->
                    <div class="sqPanel">
                        <div class="sqPanel_head inL">
                            <span>--------赎回原因--------</span>
                        </div>
                    </div>
                    <div class="fieldset1 tabel_col clearFix">
                        <div class="fieldBox col_33">
                            <div class="label">赎回原因</div>
                            <div class="field">
                                <input name="insRedmReson" id="insRedmReson" data-value="${redm.insRedmResonCode}" placeholder="" ltype="combobox" onchange="clearInsRedmReson()">
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">具体原因</div>
                            <div class="field">
                                <input name="insRedmDetailReson" id="insRedmDetailReson" data-value="${redm.insRedmDetailResonCode}" placeholder="" ltype="combobox" onchange="">
                            </div>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="label">其他原因</div>
                            <div class="field" style="width: 100%;">
                                <textarea name="otherInsRedmReson" id="otherInsRedmReson" rows="5" class="ui-textarea l-textarea" style="width:99%">${redm.otherInsRedmReson}</textarea>
                            </div>
                        </div>
                        <div class="fieldBox col_100" id="fileDiv" >
                            <div class="label">上传附件</div>
                            <div class="field">
                                <jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload2.jsp" flush="true">
                                    <jsp:param name="filePath" value="/prjRedm"/>
                                </jsp:include>
                            </div>
                        </div>
                        <!-- 附件显示 -->
                        <div class="fieldBox col_100">
                            <div style="width: 98%; margin-left: 1%;">
                                <jsp:include page="../../system/sysUlFilesRec/sysUlFileRecList.jsp" flush="true" >
                                    <jsp:param name="pkId" value="${pkId}"/>
                                    <jsp:param name="tabNm" value="${tabNm}"/>
                                </jsp:include>

                            </div>
                        </div>
                    </div>
                    <!-- hide data -->
                    <div class="fieldBox col_100" style="display: none;">
                        <div class="field">
                            <input name="prjId" id="prjId" type="text" class="ui-textbox" value="${redm.prjId}">
                            <input name="redmId" id="redmId" type="text" class="ui-textbox" value="${redm.id}">
                            <input name="payerStsCd" id="payerStsCd" type="text" class="ui-textbox" value="${redm.payerStsCd}">
                        </div>
                    </div>
                <div id="saveInsCfgDiv" class="btnsBox">
                    <span id="saveInsCfg" class="sq-button sq-button-round" onclick="return saveInfo();">保存</span>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
    var repayGrid = null;
    var payerStsCd = '${redm.payerStsCd}';
    var insPayTime = '${redm.insPayTime}';
    $(function () {
        initGrid();
        var insRedmApplyForm = liger.get("insRedmApplyForm");
        var ligerForm = $("#insRedmApplyForm").ligerForm({
            validate: true
        });
        $("#insRedmReson").ligerComboBox({
            valueField: 'key',
            textField: 'value',
            width:200,
            onChangeValue:function(value){
                if(value){
                    initInsRedmDetailResonSelectData(value);
                }else{
                    var detailResonSelectObj = liger.get("insRedmDetailReson");
                    detailResonSelectObj.selectValue(" ");
                }
            }
        });
        $("#insRedmDetailReson").ligerComboBox({
            valueField: 'key',
            textField: 'value',
            width:300
        });
        //初始化赎回原因
        initInsRedmResonSelectData();

    });
    //初始化列表
    function initGrid() {
        var prjId = $("#prjId").val();
        $("#ligergrid3").ligerGrid({
            // data: data,
            method: 'get',
            url: '<%=path%>/institution/prjinsredminfo/initPrjDtlInfo.do?prjId=' + prjId,
            columns: [
                {display: '支付表号', name: 'paySchNo', width: 200, enabledSort: true,},
                {
                    display: '我司是否已放款', name: 'isOCPay', width: 200, enabledSort: true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = "";
                        if (rowdata.isOCPay == 0) {
                            h = "否";
                        }
                        if (rowdata.isOCPay == 1) {
                            h = "是";
                        }
                        return h;
                    }
                },
                {display: '设备名', name: 'prdNm', width: 200, enabledSort: true,},
                {display: '车辆型号', name: 'prdMdl', width: 200, enabledSort: true},
                {display: '合格证编号', name: 'certNo', width: 200, enabledSort: true},
                {display: 'VIN', name: 'vin', width: 200, enabledSort: true}
            ],
            onAfterShowData: function (e) {
                var rows = e.rows;
                var i = 0;
                for (var index in rows) {
                    i += rows[index].arAmt;
                }
                $("#arAmts").text(i);
            },
            usePager: false,//是否有分页便签
            root: 'rows',
            record: 'total',
            hideLoadButton: false,
            width: '100%',
            height: '40%',
            heightDiff: -2,
            isScroll: true,//是否有滚动条
            checkbox: false,//列表是否有选择框
            enabledEdit: true,//是否能编辑
            rownumbers: true//列表是否有行号
        });
        repayGrid = liger.get("ligergrid3");
        //grid.setHeight(100);
        repayGrid.options.isSingleCheck = true;//列表是否为单选
    }

    //设置日期值
    function setFormatDateValue() {
        var deduProveTm = $("#deduProveTm").val();
        if (deduProveTm) {
            var deduProveTm = DateUtils.formatDate(new Date(deduProveTm), DateUtils.YYYY_MM_DD);
            $("#deduProveTm").val(deduProveTm);
        }
    }
    function alertSuccess(msg){
        $.ligerDialog.SQalert({content:msg, SQ_type: "success"});
    }
    //新增赎回信息等
    function saveInfo() {
        var insRedmApplyForm = liger.get("insRedmApplyForm");
        if (!insRedmApplyForm.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        var data = insRedmApplyForm.getData();
        var fileParams = getUploadResultParams();//获取附件上传的信息
        data["fileParams"] = JSON.stringify(fileParams);
        if(data.insRedmReson == ''){
            top.$.ligerDialog.SQalert({content: "请选择赎回原因", SQ_type: "warning"});
            return false;
        }
        if(data.insRedmDetailReson == ''){
            top.$.ligerDialog.SQalert({content: "请选择具体原因", SQ_type: "warning"});
            return false;
        }
        if(data.insRedmDetailReson == '99'){
            if(data.otherReson === ''){
                top.$.ligerDialog.SQalert({content: "请维护其他原因", SQ_type: "warning"});
                return false;
            }
        }
        data.id = data.redmId;
        if (fileParams.length == 0) {
            var redmId = $("#redmId").val();
            $.ajax({
                type: 'get',
                dataType: 'json',
                url: '<%=path%>/system/sysulfilesrec/initList.do?pkId=' + redmId + '&tabNm=PRJ_INS_REDM_INFO',
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg != null && msg.total > 0) {
                        data["hasFile"] = "not";
                    }
                },
                error: function (msg) {
                    top.$.ligerDialog.SQalert({content: "ajax验证附件异常", SQ_type: "error"});
                    return false;
                }
            });
        }else{
            data["hasFile"] = "yes";
        }
        updateDate(data);

    }

    function updateDate(data){
        var wait_dialog = null;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: '<%=path%>/institution/prjinsredminfo/customerManagerModify.do',
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    alertSuccess(msg.info);
                    //setInterval('Remove_navTab();callback();',1000);
                } else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            },
            error: function (msg) {
                top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                return false;
            }
        });
    }





    //初始化赎回原因
    function initInsRedmResonSelectData(){
        var data = {isPcode: '1',sysCode:'REDM008'};
        $.ajax({
            type: 'post',
            dataType:'json',
            data : data,
            url: '<%=path%>/institution/prjinsredminfo/getInsRedmReson.do',
            success:function(msg){
                if(msg.success == 1){
                    var insRedmResonSelectObj = liger.get("insRedmReson");
                    insRedmResonSelectObj.setData(msg.data);
                }else{
                    $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                }
            }
        });
    }


    //初始化具体原因
    function initInsRedmDetailResonSelectData(value){
        if(!$("#insRedmReson").length)return;
        var insRedmResonSelectObj = liger.get("insRedmReson");
        var pCode = insRedmResonSelectObj.findValueByText(value);
        var data = {isPcode: '0',sysCode:'REDM009',pCode:pCode};
        $.ajax({
            type: 'post',
            dataType:'json',
            data:data,
            url: '<%=path%>/institution/prjinsredminfo/getInsRedmReson.do',
            success:function(msg){
                if(msg.success == 1){
                    var insRedmDetailResonSelectObj = liger.get("insRedmDetailReson");
                    if(msg.data){
                        insRedmDetailResonSelectObj.setData(msg.data);
                    }else{
                        insRedmDetailResonSelectObj.clear();
                        insRedmDetailResonSelectObj.setData({});//置空下拉框数据
                    }
                }else{
                    $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                }
            }
        });
    }

    function clearInsRedmReson(){
        var insRedmResonObj = liger.get("insRedmReson");
        var _insRedmReson = insRedmResonObj.getValue();
        if (_insRedmReson == '') {
            var insRedmDetailResonSelectObj = liger.get("insRedmDetailReson");
            if(insRedmDetailResonSelectObj) {
                insRedmDetailResonSelectObj.clear();
                insRedmDetailResonSelectObj.setData({});//置空下拉框数据
            }
        }
    }



</script>
</body>
</html>